package com.yfve.eol.util;

import android.annotation.SuppressLint;
import android.hardware.Rl78Manager;
import android.util.Log;

import com.yfve.eol.EolApplication;

public class Rl78Util {
    private static final String TAG = "Rl78Util";
    private static final String RL78SERVICE = "Rl78Service";
    private static Rl78Util sInstance;
    private Rl78Manager mRl78Manager;


    @SuppressLint("WrongConstant")
    private Rl78Util() {
        mRl78Manager = (Rl78Manager) EolApplication.getAppContext().getSystemService(RL78SERVICE);
    }

    public static Rl78Util getInstance() {
        if (sInstance == null) {
            sInstance = new Rl78Util();
        }
        return sInstance;
    }

    public boolean isRl78PowerEnable() {
        int state = mRl78Manager.Rl78_get_power_stat();
        Log.i(TAG, "isRl78PowerEnable: state = " + state);
        return state == 1;
    }

    public void setRl78PowerEnable(boolean enable) {
        int powerStat = enable ? 1 : 0;
        Log.i(TAG, "setRl78PowerEnable: powerStat = " + powerStat);
        mRl78Manager.Rl78_power_enable(powerStat);
    }
}
